
#ifndef ITRIANGLECALLBACK_H
#define ITRIANGLECALLBACK_H

#include <BMesh>
#include <BSpace>

using namespace BWE;

class ITriangleCallback
{
public:
	virtual void process(const BTriangle& triangle, int triangleIndex) = 0;
};

inline void ProcessAllTriangles(const BMesh* mesh, ITriangleCallback* callback)
{
	const BVectorArray* vertices = mesh->vertices();
	const BFaceArray* faces = mesh->faces();
	int triangleIndex = 0;
	BTriangle triangle;
	for (int i = 0; i < faces->size(); i++)
	{
		const BFace& face = faces->at(i);
		triangle.a() = vertices->at(face.a());
		triangle.b() = vertices->at(face.b());
		triangle.c() = vertices->at(face.c());
		callback->process(triangle, triangleIndex++);
	}
}

#endif
